package com.hualan.dao;

import com.hualan.Util.DBUtils;
import com.hualan.bean.PanghuShopGoods;
import com.hualan.dao.PanghuGoodsDao;

import java.util.List;
import java.util.Map;

public class PanghuGoodsDaoImpl implements PanghuGoodsDao {
    @Override
    public long selectAllGoods() {
        Map<String, Object> map = DBUtils.queryOne("select count(*) as count from panghu_shop_goods");
        Long count = (Long) map.get("count");
        return count;
    }

    @Override
    public List<PanghuShopGoods> selectGoodsWithPage(int page, int size) {
        //页数
        List<PanghuShopGoods> goodsList = DBUtils.query("select * from panghu_shop_goods limit ?, ?", PanghuShopGoods.class, (page -1) * size, size);
        /*System.out.println(goodsList);*/
        return goodsList;
    }

    @Override
    public int modifyGoodsStatus(int status ,int id) {
        //根据id修改goodsStatus
        int row  = DBUtils.update("update panghu_shop_goods set goods_status = ? where goods_id = ?", status, id);
        return row;
    }
}
